{% extends "base.html" %}

{% block title %}{{nav}}{% endblock %}


{% block navbar %}
<section class="content-header">
    <h1>{{nav}}</h1>
    <ol class="breadcrumb">
        <li><i class="fa fa-dashboard"></i> 当前位置</li>
        <li class="active">{{nav}}</li>
        <li class="active">服务器配置</li>
    </ol>
</section>
{% endblock %}


{% block content %}
<div class="box box-primary">
    <form method="post" enctype="multipart/form-data">
        {{form.hidden_tag()}}
        <div class="box-header with-border">
            {% include 'message.html' %}
        </div>

        <div class="box-body">
            {% for field in form %}
            {% if field.type in ("StringField","IntegerField")%}
            <div class="col-md-6">
                <div class="form-group">
                    <label>{{field.label}}</label>
                    {{field(class_="form-control")}}
                </div>
            </div>
            {% endif %}
            {% if field.type == "BooleanField" %}
            <div class="col-md-12">
                <div class="form-group">
                    <label>{{field.label}}</label>
                    <div>{{field(class_="form-control")}}</div>
                </div>
            </div>
            {% endif %}
            {% if field.type == "PasswordField" %}
            <div class="col-md-6">
                <div class="form-group">
                    <label>{{field.label}}</label>
                    <div>{{field(class_="form-control")}}</div>
                </div>
            </div>
            {% endif %}
            {% if field.type=="SubmitField"%}
            <div class="box-footer">
                <div class="col-md-12">
                    {{field(class_="btn btn-primary pull-right")}}
                </div>
            </div>
            {% endif %}
            {% if field.type=="FileField"%}
            <div class="col-md-6">
                <div class="form-group">
                    <label>{{field.label}}</label>
                    {{field(class_="form-control")}}
                </div>
            </div>
            {% endif %}
            {% endfor%}
        </div>


    </form>
</div>
{% endblock %}

{% block scripts %}
<script>
    function initPage() {
        {% for field in form if field.type == "BooleanField" %}
        switch_value = $('#{{field.name}}')[0].checked
        $('#{{field.name}}').bootstrapSwitch({
            state: switch_value,
            onText: '生效',
            offText: '失效'

        });
        {% endfor %}
    }
</script>
{% endblock %}